#include<bits/stdc++.h>
using namespace std;
// using namespace std::chrono;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
#define endl "\n";

namespace DBG
{
	template <class T>
	ostream& operator << (ostream& os,const vector<T> &v)
	{
		os<<"[ ";
		for (int i=0;i<v.size();i++)
		{
			os<<v[i];
			if (i+1<v.size())
				os<<", ";
		}
		os<<" ]";
		return os;
	}

	template <class T,size_t N>
	ostream& operator << (ostream& os,const array<T,N> &v)
	{
		os<<"[ ";
		for (int i=0;i<v.size();i++)
		{
			os<<v[i];
			if (i+1<v.size())
				os<<", ";
		}
		os<<" ]";
		return os;
	}

	template <class T>
	void _dbg(const char *f,T t)
	{
		cerr<<f<<'='<<t<<'\n';
	}

	template <class A,class... B>
	void _dbg(const char *f,A a,B... b)
	{
		while (*f!=',') cerr<<*f++;
		cerr<<'='<<a<<",";
		_dbg(f+1,b...);
	}

	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
}

using namespace DBG;


const int M=1e5+5;
const int N=5e4+5;



void solve(){
	int n,m;
	cin>>n>>m;
	vector<vector<int>>s(n+1);
	int cnt=0;
	vector<int>vis(m+1,0);
	for(int i=0;i<n;i++){
		int l;
		cin>>l;
		for(int j=0;j<l;j++){
			int num;
			cin>>num;
			s[i].push_back(num);
			vis[num]++;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<s[i].size();j++){
			vis[s[i][j]]--;
		}
		int f=1;
		for(int j=1;j<=m;j++){
			if(vis[j]==0){
				f=0;
				break;
			}
		}
		for(int j=0;j<s[i].size();j++){
			vis[s[i][j]]++;
		}
		if(f)cnt++;
		if(cnt==2)break;
	}
	if(cnt<2){
		cout<<"NO"<<endl;
		return;
	}
	cout<<"YES"<<endl;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	// auto start = high_resolution_clock::now();
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	// auto end = high_resolution_clock::now();
    // auto duration = duration_cast<microseconds>(end - start);
    // cout << "Time: " << duration.count()/1000 << " ms" << endl;
	return 0;
}